//
//  FacView.m
//  PlayADS
//
//  Created by 周莹 on 15/12/23.
//  Copyright © 2015年 周莹. All rights reserved.
//

#import "FacView.h"
// 左右两边的间距
#define MARGIN_1 10.0f
// 按钮的Y值
#define IMAGE_Y  18.0f
// 按钮的Y值
#define BUTTON_Y  18.0f
// 男女之间的间距
#define MARGIN_2 5.0f

// 第一个按钮的宽
#define BUTTON_1_W 95.0f

// 按钮的高
#define BUTTON_H 30.0f

@implementation FacView

-(instancetype)initWithFrame:(CGRect)frame WithImage:(UIImage *)image withFacName:(NSString *)facname Business:(NSString *)business FacSituation:(NSString *)sityation adress:(NSString *)adress web:(NSString *)web Nunber:(NSInteger )number {
    self = [super initWithFrame:frame];
    if (self) {
        
        
    }
    return self;

}


- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initControl];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initControl];
        
    }
    return self;
}

/** 初始化控件 **/
-(void) initControl{
    
    self.mapButton = [self addButton];
    self.CallButton = [self addButton];
    self.webButton = [self addButton];
    self.Logoimage = [self  addImage];
    
    
   }

-(void)logoimageName:(NSString *)logoimageName  image:(NSString *)image1Name image:(NSString *)image2Name imagename3:(NSString *)image3Name{
    self.Logoimage = [[UIImageView  alloc] initWithImage:[UIImage  imageNamed:logoimageName]];
}
/** 快捷创建 **/
-(UIImageView *)addImage {
    UIImageView * image = [[UIImageView alloc] init];
    [self  addSubview:image];


    return image;
}

/** 快捷创建 **/
-(UIButton *)addButton{
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundColor:[UIColor redColor]];
    [self  addSubview:button];
    button.titleLabel.font = [UIFont  boldSystemFontOfSize:15];
    
    
    return button;
}


- (void)layoutSubviews{
    [super layoutSubviews];
    [self setControlFrame];
}

/** 设置子控件位置 **/
-(void)setControlFrame{
    
//    
//        CGFloat btn1W = SCALE_WIDTH(BUTTON_1_W);
//        CGFloat btn1H = SCALE_WIDTH(BUTTON_H);
//        CGFloat btn1X = MARGIN_1;
//        CGFloat btn1Y = BUTTON_Y;
//    
//    self.Logoimage.frame = CGRectMake(btn1X, btn1Y, btn1W, btn1H);
//    
    
    
    //button1
    CGFloat btn1W = SCALE_WIDTH(BUTTON_1_W);
    CGFloat btn1H = SCALE_WIDTH(BUTTON_H);
    CGFloat btn1X = MARGIN_1;
    CGFloat btn1Y = BUTTON_Y;
    
    self.Logoimage.frame = CGRectMake(btn1X, btn1Y, btn1W, btn1H);
    
    
    
//    
//    //button2
//    
//    CGFloat w = (SCREEN_WIDTH - (MARGIN_1 * 2) - (MARGIN_2 * 3) - btn1W) / 3;
//    
//    CGFloat btn2W = w;
//    CGFloat btn2H = btn1H;
//    CGFloat btn2X = CGRectGetMaxX(self.mapButton.frame) + MARGIN_2;
//    CGFloat btn2Y = BUTTON_Y;
//    
//    self.webButton.frame = CGRectMake(btn2X, btn2Y, btn2W, btn2H);
//    
//    
//    
//    
//    //button3
//    
//    CGFloat btn3W = w;
//    CGFloat btn3H = btn1H;
//    CGFloat btn3X = CGRectGetMaxX(self.webButton.frame) + MARGIN_2;
//    CGFloat btn3Y = BUTTON_Y;
//    
//    self.CallButton.frame = CGRectMake(btn3X, btn3Y, btn3W, btn3H);
//    
    
    
    
    
}







@end
